<template>
  <div class="login-wrap" style="color: red">
    <div class="ms-login">
      <el-form :model="userForm" label-width="0px" class="demo-ruleForm">
        <el-input v-model="userForm.username" placeholder="请输入用户名"></el-input>
        <el-input v-model="userForm.password" type="password" placeholder="请输入密码"></el-input>
        <div>
          <el-button type="primary" @click="submit('userForm')">登录</el-button>
          <el-button type="primary" @click="test()"><h1>test</h1></el-button>
          <el-button type="primary" @click="test2()"><h1>test</h1></el-button>
          <el-button type="primary" @click="test3()"><h1>test</h1></el-button>
          <el-button type="primary" @click="test4()"><h1>test</h1></el-button>
          <el-button type="primary" @click="upgrade1()"><h1>upgrade1</h1></el-button>
          <el-button type="primary" @click="upgrade2()"><h1>upgrade2</h1></el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
  import {login} from "~/ajax/ajax";
  import {test} from "~/ajax/ajax";
  import {test3} from "~/ajax/ajax";
  import {test4} from "~/ajax/ajax";
  import {upgrade1} from "~/ajax/ajax";
  import {upgrade2} from "~/ajax/ajax";

  export default {
    name: "login",
    data: function () {
      return {
        userForm: {
          username: null,
          password: null
        }
      }

    }, methods: {
      submit(formName) {
        let username = this.userForm.username;
        let password = this.userForm.password;
        if (!username || !password) {
          this.$message.error("请正确填写")
        }
        login(this.userForm).then(result => {
          if (result && result.status === 200) {
            sessionStorage.setItem("token", "Bearer " + result.data.data);
          } else {
            this.$message.error(result.message);
          }
        })
      },
      test() {
        test({asdf: "afddsa"}).then(result => {
          console.log(result)
        })
      },
      test2() {
        test({asdf: "afddsa"}).then(result => {
          console.log(result)
        })
      },
      test3() {
        test3().then(result => {
          console.log(result)
        })
      },
      test4() {
        test4().then(result => {
          console.log(result)
        })
      },
      upgrade1() {
        upgrade1().then(result => {
          console.log(result)
        })
      }, upgrade2() {
        upgrade2().then(result => {
          console.log(result)
        })
      }
    }
  }
</script>

<style scoped>

</style>